<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>2.methods实现</title>
    <!-- 引入Vue -->
    <script type="text/javascript" src="../../js/vue.js"></script>
  </head>
  <body>
    <!-- 准备好一个容器-->
    <div id="demo">
      <span>当前求和为：{{n}}</span> <button @click="add">点我n+1</button>
      <hr>
      姓：<input type="text" v-model="firstName"> <br>
      名：<input type="text" v-model="lastName"> <br>
      全名：<span>{{fullName()}}</span> <br>
      全名：<span>{{fullName()}}</span> <br>
      全名：<span>{{fullName()}}</span> <br>
      全名：<span>{{fullName()}}</span> <br>
      全名：<span>{{fullName()}}</span> <br>
      全名：<span>{{fullName()}}</span> <br>

      <!-- <button @click="test">点我</button> -->
      <!-- <button @click="test(678)">点我</button> -->
    </div>

    <script type="text/javascript">
      new Vue({
        el:'#demo',
        data:{
          firstName:'zhang',
          lastName:'san',
          n:1
        },
        methods:{
          fullName(){
            console.log('fullName调用了')
            return this.firstName.slice(0,1).toUpperCase() + this.firstName.slice(1) + '-' + this.lastName
          },
          add(){
            this.n += 1
          }
        }
      })
    </script>
  </body>
</html>